package com.mfin.bs.mappers.impl;

import com.mfin.bom.interfaces.ILoanMaster;
import com.mfin.vo.interfaces.IMappable;
import com.mfin.vo.loan.LoanMasterVO;

public class LoanMasterMapper extends BaseMapper {

	@Override
	protected boolean doMap(IMappable fromArg, IMappable toArg) {
		boolean canPerformMap = false;

		if (fromArg instanceof ILoanMaster && toArg instanceof LoanMasterVO) {
			canPerformMap = true;
			performMap((ILoanMaster) fromArg, (LoanMasterVO) toArg);
		} else if (fromArg instanceof LoanMasterVO
				&& toArg instanceof ILoanMaster) {
			performMap((LoanMasterVO) fromArg, (ILoanMaster) toArg);
			canPerformMap = true;
		}
		return canPerformMap;
	}

	private void performMap(LoanMasterVO fromArg, ILoanMaster toArg) {
		toArg.setLoanName(fromArg.getLoanName());
	}

	private void performMap(ILoanMaster fromArg, LoanMasterVO toArg) {
		toArg.setLoanType(fromArg.getLoanType());
		toArg.setLoanName(fromArg.getLoanName());
	}
}
